#!/usr/bin/env bash

current_project=ruoyi-admin

project_jar_name=${current_project}.jar

#cd ${current_project}
jar_name=ruoyi-admin.jar
echo $PROJECT_PATH $jar_name

echo "Stopping" ${jar_name}
pid= `ps -ef | grep $jar_name | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
echo "kill -9 的pid:" $pid
kill - 9 $pid
fi


mkdir ./docker_build
mvn package
cp ./target/${project_jar_name} docker_build/
cp ./deploy/Dockerfile docker_build/
echo "start docker build"
tag='${project_jar_name}'
sed -e "s/${tag}/${project_jar_name}" -i Dockerfile
docker build -t ${current_project} docker_build/

docker run --name ${current_project} -p 18081:18081 -d ${current_project}